﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PokerClient.Connection.CommandHandlers;
using PokerClient.Connection;

namespace PokerClient.Commands.CommandHandlers
{
	class regProtHandles : absAuthReg, IHandle
	{
		private MainWindow regist;
		private AuthRegStates state;
		public String message = "";
		private Client myClient;

		public regProtHandles(Client myClient,MainWindow regist)
		{
			this.myClient = myClient;
			this.regist = regist;
		}

		public override void assignCommand(String commands)
		{
			this.commands = commands.Split(' ');
		}

		public override String work()
		{
			String ans = "";
			switch(commands[0])
			{
				case "REGISTER-FAIL":
					ans = commands[1];
					state = AuthRegStates.REGISTER_FAIL;
					break;
				case "REGISTER-ACK":
					ans = "Success";
					state = AuthRegStates.REGiSTER_SUCCESS;
					break;
				default:
					ans = "FAIL";
					break;
			}
			return (message = ans);
		}

		public override void analyze()
		{
			this.regist.updateStatus(message);
		}
	}
}
